#!/bin/bash

wlist="wlist.txt"

files=$(ls ${1}/)
for file in $files 
do
    input="${1}/${file}"
    
    time1=$(date)
    echo ""	
    echo ${time1}

    lb=`grep "^c pre_LB " $input | cut -d ' ' -f 3`
    k=`grep "^c k " $input | cut -d ' ' -f 3`
    filename="${file%%-k*}"
    bef=`grep "^$filename" $wlist`

    if [ -n "$bef" ]
    then 
        echo "Wrong before !!!"
    elif [ -z "$lb" -a -z "$k" ] 
    then
        echo "input file: $input"
        echo "prework wrong !!!"
    else 
        timeout 12000 ../../../KDefective -r ${input} -O solve -a MADEC -D Set -k ${k} -M ${lb} -t 10800
    fi
done

